package logic

import (
	"context"

	"e4ting/internal/svc"
	"e4ting/pb/e4ting"

	"github.com/zeromicro/go-zero/core/logx"
)

type AccountInLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAccountInLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AccountInLogic {
	return &AccountInLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 入账
func (l *AccountInLogic) AccountIn(in *e4ting.BillingReq) (*e4ting.UpdateResponse, error) {

	err := l.svcCtx.UtxoModel.UserAddMoney(int64(in.AccountID), int64(in.Money), in.Detail)
	if err != nil {
		return &e4ting.UpdateResponse{
			Code: 400,
			Err: err.Error(),
		}, nil
	}
	return &e4ting.UpdateResponse{
		Code: 200,
		Data: "入账成功",
	}, nil
}
